/*
 * Copyright (C) 2012 rothens
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package rpg.gfx;

import rpg.console.Console;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import rpg.Game;

/**
 *
 * @author rothens
 */
public class Overlay extends Bitmap {

    private static Overlay instance;
    public List<OverlayEffect> overlay = new ArrayList<OverlayEffect>();

    public static Overlay getInstance() {
        return instance;
    }

    public Overlay(int width, int height) {
        super(width, height);
        instance = this;

    }

    public void render() {
        clear();
        Iterator<OverlayEffect> ite = overlay.iterator();
        while(ite.hasNext()) {
            OverlayEffect next = ite.next();
            if(next.tick()){
                draw(next, next.getxPos(), next.getyPos());
            } else {
                ite.remove();
            }
        }
	draw(Screen.getInstance().gui,0,0);
        Console c = Console.getInstance();
        if(c.isVisible()){
            c.tick();
            draw(c,5,5);
        }
    }

    public void addOverlay(OverlayEffect eff) {
        overlay.add(eff);
    }
}
